package com.aiyige.page.home.model;

import android.os.Parcel;
import android.os.Parcelable;

public class FollowItem implements Parcelable {
    String name;
    String avatar;
    String id;
    boolean followed;
    String followId;

    public FollowItem() {
    }

    private FollowItem(Builder builder) {
        setName(builder.name);
        setAvatar(builder.avatar);
        setId(builder.id);
        setFollowed(builder.followed);
        setFollowId(builder.followId);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isFollowed() {
        return followed;
    }

    public void setFollowed(boolean followed) {
        this.followed = followed;
    }

    public String getFollowId() {
        return followId;
    }

    public void setFollowId(String followId) {
        this.followId = followId;
    }

    public static final class Builder {
        private String name;
        private String avatar;
        private String id;
        private boolean followed;
        private String followId;

        private Builder() {
            name = "";
            avatar = "";
            id = "";
            followed = false;
            followId = "";
        }

        public Builder name(String val) {
            name = val;
            return this;
        }

        public Builder avatar(String val) {
            avatar = val;
            return this;
        }

        public Builder id(String val) {
            id = val;
            return this;
        }

        public Builder followed(boolean val) {
            followed = val;
            return this;
        }

        public Builder followId(String val) {
            followId = val;
            return this;
        }

        public FollowItem build() {
            return new FollowItem(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.name);
        dest.writeString(this.avatar);
        dest.writeString(this.id);
        dest.writeByte(this.followed ? (byte) 1 : (byte) 0);
        dest.writeString(this.followId);
    }

    protected FollowItem(Parcel in) {
        this.name = in.readString();
        this.avatar = in.readString();
        this.id = in.readString();
        this.followed = in.readByte() != 0;
        this.followId = in.readString();
    }

    public static final Creator<FollowItem> CREATOR = new Creator<FollowItem>() {
        @Override
        public FollowItem createFromParcel(Parcel source) {
            return new FollowItem(source);
        }

        @Override
        public FollowItem[] newArray(int size) {
            return new FollowItem[size];
        }
    };
}
